package com.dhp.bkOjjudgeservice.codesandbox.impl;

import cn.hutool.http.HttpUtil;
import cn.hutool.json.JSONUtil;
import com.dhp.bkOjjudgeservice.codesandbox.CodeSandBox;
import com.dhp.model.codesandbox.ExecuteRequest;
import com.dhp.model.codesandbox.ExecuteResponse;

/**
 * 远程代码沙箱
 */
public class RemoteCodeSandBox implements CodeSandBox {

    private static final String REMOTE_URL = "http://82.156.9.221:8070/codeSandBox/exec";
    @Override
    public ExecuteResponse execute(ExecuteRequest executeRequest) {
        String execute = HttpUtil.createPost(REMOTE_URL).body(JSONUtil.toJsonStr(executeRequest)).execute().body();
        ExecuteResponse executeResponse = JSONUtil.toBean(execute, ExecuteResponse.class);
        return executeResponse;
    }
}
